package 代理模式;

/**
 * 文 件 名 称：Intermediary.
 * 文 件 说 明：中介
 * 创   建   人：zpen.
 * 创 建 时 间：2018/5/9 11:28.
 */
public class Intermediary {
    private String name;
    private String condition;
    private Customer customer = null;
    private String type;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCondition() {
        return condition;
    }

    public void setCondition(String condition) {
        this.condition = condition;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Intermediary(String type,String name,String condition) {
        setName(name);
        setCondition(condition);
        if("cu".equals(type)){
            this.type = "买家";
            customer = new Tenant(name,condition);
        }else if("ho".equals(type)){
            this.type = "卖家";
            customer = new Homeowner(name,condition);
        }
    }

    public void business(String condition){
        if(this.condition.equals(condition)){
            System.out.println("恭喜您，我们找到了满足您条件的"+type);
            customer.business();
        }else {
            System.out.println("对不起，现在还没有满足您条件的"+type);
        }
    }


}
